package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    List<Dish> page(DishPageQueryDTO dishPageQueryDTO);
    @AutoFill(value = OperationType.INSERT)
    void add(Dish dish);
    @AutoFill(value = OperationType.UPDATE)
    void update(Dish dish);
    @Select("select * from dish where id = #{id}")
    Dish getById(Long id);

    void delete(Long[] ids);

    @Update("update dish set status = #{status} where id = #{id}")
    void status(Integer status, Long id);
    @Select("select * from dish where status = 1 and category_id = #{categoryId}")
    List<Dish> list(Long categoryId);
    @Select("select count(id) from dish where status = #{status}")
    Integer getnumberByStatus(Integer  status);
}
